package javabase.schoolwork.day6_07;

/**
 * @author fance
 * @date 2018/6/7 20:09
 */
class Ticket extends Thread {
    private int ticket = 5;
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (ticket > 0) {
                System.out.println("mai " + ticket--);
            }
             }
    }
}
class TicketII implements Runnable {
    private int ticket = 5;
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (ticket > 0) {
                System.out.println("mai " + ticket--);
            }
             }
    }
}
public class Demo04 {
    public static void main(String[] args) {
//        Ticket ticket1 = new Ticket();
//        Ticket ticket2 = new Ticket();
//        Ticket ticket3 = new Ticket();
//        ticket1.start();
//        ticket2.start();
//        ticket3.start();
        TicketII ticket1 = new TicketII();
        new Thread(ticket1).start();
        new Thread(ticket1).start();
        new Thread(ticket1).start();

    }
}
